package com.quanyan.vote.web;

import com.alibaba.fastjson.JSON;
import com.quanyan.api.APIResponse;
import com.quanyan.api.enums.ApiResponseEnum;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.vote.entity.db.TbVoteDayIncre;
import com.quanyan.vote.entity.vo.req.ReqDayIncrementMsg;
import com.quanyan.vote.entity.vo.req.ReqExpertAdmin;
import com.quanyan.vote.entity.vo.req.ReqVoteDetailAdmin;
import com.quanyan.vote.entity.vo.resp.RespExpertAdmin;
import com.quanyan.vote.entity.vo.resp.RespVoteDetailAdmin;
import com.quanyan.vote.service.TbVoteExpertAdminService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Administrator on 2016/7/26.
 */
@RestController
@RequestMapping(value = "admin/api/vote")
public class TbUserAdminController {

    private static final Logger LOGGER = LoggerFactory.getLogger(TpUserController.class);

    @Autowired
    private TbVoteExpertAdminService tbVoteExpertAdminService;

    /**
     *后管达人排名页面
     * @param reqExpertAdmin
     * @return
     */
    @RequestMapping(value = "getExpertAdminMsg",method = RequestMethod.POST)
    public APIResponse<PageObj<List<RespExpertAdmin>>> getExpertAdminMsg(@RequestBody ReqExpertAdmin reqExpertAdmin){
        LOGGER.debug("----getExpertAdminMsg----->>>>>"+ JSON.toJSONString(reqExpertAdmin));
        if (null == reqExpertAdmin){
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_CANT_BE_EMPTY);
        }
        return tbVoteExpertAdminService.getExpertAdminMsg(reqExpertAdmin);
    }

    /**
     * 后管达人投票详情页面
     * @param reqVoteDetailAdmin
     * @return
     */
    @RequestMapping(value = "getVoteDetailAdmin",method = RequestMethod.POST)
    public APIResponse<PageObj<List<RespVoteDetailAdmin>>> getVoteDetailAdmin(@RequestBody ReqVoteDetailAdmin reqVoteDetailAdmin){
        LOGGER.debug("----getVoteDetailAdmin----->>>>>"+ JSON.toJSONString(reqVoteDetailAdmin));
        if (null == reqVoteDetailAdmin){
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_CANT_BE_EMPTY);
        }
        return tbVoteExpertAdminService.getVoteDetailAdmin(reqVoteDetailAdmin);
    }

    /**
     * 导出达人排名数据
     * @param reqExpertAdmin
     * @return
     */
    @RequestMapping(value = "importExpertAdminMsg",method = RequestMethod.POST)
    public APIResponse<List<RespExpertAdmin>> importExpertAdminMsg(@RequestBody ReqExpertAdmin reqExpertAdmin){
        LOGGER.debug("----importExpertAdminMsg----->>>>>"+ JSON.toJSONString(reqExpertAdmin));
        if (null == reqExpertAdmin){
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_CANT_BE_EMPTY);
        }
        return tbVoteExpertAdminService.importExpertAdminMsg(reqExpertAdmin);
    }

    /**
     * 导出达人投票详情数据
     * @param reqVoteDetailAdmin
     * @return
     */
    @RequestMapping(value = "importVoteDetailAdmin",method = RequestMethod.POST)
    public APIResponse<List<RespVoteDetailAdmin>> importVoteDetailAdmin(@RequestBody ReqVoteDetailAdmin reqVoteDetailAdmin){
        LOGGER.debug("----importVoteDetailAdmin----->>>>>"+ JSON.toJSONString(reqVoteDetailAdmin));
        if (null == reqVoteDetailAdmin){
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_CANT_BE_EMPTY);
        }
        return tbVoteExpertAdminService.importVoteDetailAdmin(reqVoteDetailAdmin);
    }

    /**
     * 插入日增量
     * @return
     */
    @RequestMapping(value = "countDayIncrement",method = RequestMethod.POST)
    public APIResponse<Boolean> countDayIncrement(){
        LOGGER.debug("----countDayIncrement----->>>>>");
        return tbVoteExpertAdminService.countDayIncrement();
    }

    /**
     * 后管查看达人每日票数
     * @param reqDayIncrementMsg
     * @return
     */
    @RequestMapping(value = "getDayIncrementMsg",method = RequestMethod.POST)
    public APIResponse<PageObj<List<TbVoteDayIncre>>> getDayIncrementMsg(@RequestBody ReqDayIncrementMsg reqDayIncrementMsg){
        LOGGER.debug("----getDayIncrementMsg----->>>>>");
        LOGGER.debug("----importVoteDetailAdmin----->>>>>"+ JSON.toJSONString(reqDayIncrementMsg));
        if (null == reqDayIncrementMsg){
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_CANT_BE_EMPTY);
        }
        return tbVoteExpertAdminService.getDayIncrementMsg(reqDayIncrementMsg);
    }


}
